package com.itheima.health.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.health.dao.PermissionDao;
import com.itheima.health.entity.PageResult;
import com.itheima.health.pojo.Permission;
import com.itheima.health.service.PermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ：w
 * @date ：Created in 2019/7/30 0030
 * @description ：
 * @version: 1.0
 */
@Service
@Slf4j
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionDao permissionDao;
    @Override
    public PageResult findPermissionByCondition(Integer currentPage,Integer pageSize,String queryString) {
        log.debug("<<<<<<<<<<<currentPage,pageSize,queryString:{}"+currentPage+","+pageSize+","+","+queryString);
        PageHelper.startPage(currentPage, pageSize);
        Page<Permission> permissions = permissionDao.selectCondition(queryString);
        return new PageResult(permissions.getTotal(), permissions.getResult());
    }

    @Transactional
    @Override
    public void addOneRecord4Permission(Permission permission) {
        permissionDao.addOneRecord4Permission(permission);
    }

    @Override
    public Permission findPermissionById(Integer id) {
        return permissionDao.findPermissionById(id);
    }

    @Transactional
    @Override
    public void updateOneRecord4Permission(Permission permission) {
        permissionDao.updateOneRecord4Permission(permission);
    }

    @Transactional
    @Override
    public void delOneRecord4Permission(Integer id) {
        permissionDao.delOneRecord4Permission(id);
    }
}
